//贪心算法，活动选择问题

pub struct Activity {
    pub id:i32,
    pub start:i32,
    pub end:i32,
}

pub fn activity(activities:&[&Activity])->Vec<&Activity>{
    let sortedActis = activities.sort_by_key(|a| a.end);
    fn inter(activities:&[&Activity],index:usize,result:mut Vec<&Activity>)->Vec<&Activity>{
        if(index>=activities.len()){
            return result
        }
        result.push(activities[index]);
        let endTime = activities[index].end;
        let nextStartPosition = activities[index..activities.len()].position(|ac|ac.start>=endTime);
        nextStartPosition match {
            Option::None -> return result
            Option::Some(p) -> return inter(activities,p,result)
        };
    }
    inter(sortedActis)
}
